<style lang="less">
@import "./login.less";
.login-con {
  background-image: url("../../assets/images/bg_inside.png");
  background-size: 100%;
  height: 610px;
}
</style>

<template>
  <div class="login">
    <div class="login-con">
      <div class="login-left-bg lf"></div>
      <div class="form-con rt">
        <p class="login-tip" style="margin-top:100px">
          <!-- <img src="../../assets/images/logo1.png" alt /> -->
        </p>
        <h4>爱车精灵小程序后台管理系统</h4>
        <login-form @on-success-valid="handleSubmit"></login-form>
      </div>
    </div>
  </div>
</template>

<script>
import LoginForm from "_c/login-form";
import { mapActions, mapMutations } from "vuex";
import axios from "@/libs/api.request";
export default {
  components: {
    LoginForm
  },
  created() {
    this.$store.commit("setToken", "98896dd87f993b355273b6773c3cbe8c");
    this.$router.push({
      name: this.$config.homeName
    });
  },
  methods: {
    ...mapMutations(["setHasGetInfo"]),
    ...mapActions(["handleLogin", "getUserInfo"]),
    handleSubmit({ userName, password }) {
      this.handleLogin({ userName, password }).then(res => {
        if (res) {
          this.$Message.error(res);
        } else {
          this.getUserInfo().then(response => {
            if (response) {
              this.$router.push({
                name: this.$config.homeName
              });
            }
          });
        }
      });
    }
  }
};
</script>

<style>
</style>
